package com.rbcs.init;

import java.util.List;

import javax.annotation.PostConstruct;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.rbcs.base.company.CompanyHelp;
import com.rbcs.base.model.Company;

public class Itializer {
	
	@Autowired(required = true)
	private SessionFactory sessionFactory;
	
	@PostConstruct
	@SuppressWarnings("unchecked")
	public void init(){
		Session session = sessionFactory.openSession();
		List<Company> coms = session.createQuery("from Company").list();
		if (!coms.isEmpty()){
			CompanyHelp.COMPAY = (Company)coms.get(0);
		}else{
			CompanyHelp.COMPAY = new Company("");
		}
		
	}

}
